﻿#pragma once

#include "TitleBarControl.g.h"

namespace winrt::NovelReader::implementation
{
	struct TitleBarControl : TitleBarControlT<TitleBarControl>
	{
		TitleBarControl();
		void InitializeComponent();
		winrt::NovelReader::TitleBarViewModel ViewModel();

	private:
		void ApplySettings(); 

		template<typename T>
		void UpdateRadioFlyoutMenuItemStatus(winrt::Microsoft::UI::Xaml::Controls::MenuFlyoutSubItem subItem, T const& targetValue)
		{
			for (auto item : subItem.Items())
			{
				auto radioMenuItem = item.as<winrt::Microsoft::UI::Xaml::Controls::RadioMenuFlyoutItem>();
				auto parameterValue = winrt::unbox_value<T>(radioMenuItem.CommandParameter());
				if (parameterValue == targetValue) {
					radioMenuItem.IsChecked(true);
					break;
				}
			}
		}

		winrt::NovelReader::TitleBarViewModel m_viewModel{nullptr}; 
		winrt::NovelReader::Settings m_userSettings {nullptr}; 
	};
}

namespace winrt::NovelReader::factory_implementation
{
	struct TitleBarControl : TitleBarControlT<TitleBarControl, implementation::TitleBarControl>
	{
	};
}
